/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package music;

import java.awt.Graphics;
import music.types.ClefType;
import music.types.NoteTypes;

/**
 *
 * @author TJ
 */
public abstract class AbstractNote {
    private Score score;
    private Staff staff;
    private Measure parent;
    private NoteTypes type;
    private int dots=0;
    private float beat;
    public boolean isRest(){return false;}
    public double getLength(TimeSignature t){
        return type.getLength(t)*getMultFactor();
    }
    public float getBeat(){return beat;}
    public void setBeat(float f){beat=f;}
    public abstract void renderNote(Graphics g,SpacingOptions s,int x,ClefType c);
    public AbstractNote(NoteTypes t) {
        type=t;
    }
    public AbstractNote(Measure m,NoteTypes n, int dots) {}
    public void setNoteType(NoteTypes t) {type=t;}
    public void setDots(int d){if(d<0) {d=0;}dots=d;}
    protected double getMultFactor() {
        double mul=1;
        for(int i=-1;i>=-1*dots; i--) {
            mul+=Math.pow(2, i);
        }
        return mul;
    }
    //private static boolean isLegal(Measure m,AbstractNote n,)
    public Score getScore() {return score;}
    public Staff getStaff(){return staff;}
    public Measure getMeasure(){return parent;}
    public void setMeasure(Measure m){parent=m;}
    public NoteTypes getType(){return type;}
    
}
